/*
Copyright 2002-2003 The University of Texas at Austin

Authors: Anthony Thane <thanea@ices.utexas.edu>
Vinay Siddavanahalli <skvinay@cs.utexas.edu>
Advisor: Chandrajit Bajaj <bajaj@cs.utexas.edu>

This file is part of Volume Rover.

Volume Rover is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Volume Rover is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with iotree; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef XOOMEDOUT_H
#define XOOMEDOUT_H

#include <QFrame>
#include <QPainter>

#include "XoomedIn.h"

using namespace PBVP;

class XoomedOut : public QFrame {
	Q_OBJECT
public:
	XoomedOut( TransferMap* colorTableInformation, XoomedIn* xoomedIn, QWidget *parent, const char *name );
	virtual ~XoomedOut();

protected:
	virtual void paintEvent(QPaintEvent *);

	virtual void drawContentsVertical( QPainter* painter );
	virtual void drawContentsHorizontal( QPainter* painter );

	void drawColorMapVertical( QPainter* painter, QRect rect );
	void drawControlBarVertical( QPainter* painter, QRect rect, double doublePos );

	void drawColorMapHorizontal( QPainter* painter, QRect rect );
	void drawControlBarHorizontal( QPainter* painter, QRect rect, double doublePos );

	TransferMap* m_ColorTableInformation;
	double m_RangeMin;
	double m_RangeMax;

	enum HANDLE {
		MIN_HANDLE, MAX_HANDLE, NO_HANDLE
	};

	HANDLE m_SelectedHandle ;

	void mouseMoveEvent( QMouseEvent* q );
	void mousePressEvent( QMouseEvent* q );
	void mouseReleaseEvent( QMouseEvent* q );

	void mouseMoveEventVertical( QMouseEvent* q );
	void mousePressEventVertical( QMouseEvent* q );
	void mouseReleaseEventVertical( QMouseEvent* q );

	void mouseMoveEventHorizontal( QMouseEvent* q );
	void mousePressEventHorizontal( QMouseEvent* q );
	void mouseReleaseEventHorizontal( QMouseEvent* q );

	int getIntPosVertical(double doublePos, QRect rect);
	double getDoublePosVertical(int intPos, QRect rect);

	int getIntPosHorizontal(double doublePos, QRect rect);
	double getDoublePosHorizontal(int intPos, QRect rect);

signals:
	void minChanged( double value );
	void minExploring( double value );
	void maxChanged( double value );
	void maxExploring( double value );
};

#endif
